/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.PreparedStatement;
import model.Release;

/**
 *
 * @author Adriano
 */
public class ReleaseDAO implements DAO {

    private final DataSource dataSource;

    public ReleaseDAO() {
        dataSource = new DataSource();
    }

    public void create(Object o) {
        try {

            String sql = "INSERT INTO releases VALUES (?,?,?,?,?,?,?,?)";
            PreparedStatement ps = dataSource.getConnection().prepareStatement(sql);

            Release lancamento = (Release) o;

            
            ps.setString(1, lancamento.getLstNatureza());
            ps.setString(2, lancamento.getTxtConta());
            ps.setString(3, lancamento.getTxtDecricaoConta());
            ps.setString(4, lancamento.getTxtValor());
            ps.setString(5, lancamento.getTxtSaldo());
            ps.setString(5, lancamento.getLstHistorico());
            ps.setString(7, lancamento.getTxtComplementoHistorico());
            ps.setString(8, lancamento.getTxtdate());
           
            
            int res = ps.executeUpdate();
            ps.close();
            if (res == 0) {
                System.err.println("LANCAMENTODAO.CREATE - Nenhum lancamento registrado !");

            }

        } catch (Exception e) {
             System.err.println("LANCAMENTODAO.CREATE - " + e.getMessage());

        }
    }

    public void delete(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public void update(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    public Object read(Object o) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
    
    
     public void closeDAO() {
        dataSource.closeConnection();
    }

}
